#include <Graph.h>
#include <stdio.h>
#include <string.h>

long*** var;
long vari;
long k;
long n;
FILE* out;
char* source;

void addEdgeRestriction(long v, long u, long w){
	long l;
	if(source[v] == 's'){
		for(l = 0; l < k; l++){
			fprintf(out,"1x%lu + 1x%lu <= 1 \n", var[v][u][l], var[v][w][l]);
		}
	}else{
		for(l = 0; l < k; l++){
			fprintf(out,"1x%lu +1x%lu -1x%lu <= 0 \n", var[v][u][l], var[v][w][l], var[v][v][l]);
		}
	}
}

void addSingleRestriction(long v, long u){
	long l;
	if(source[v] != 's'){
		for(l = 0; l < k; l++){
			fprintf(out,"1x%lu -1x%lu <= 0 \n", var[v][u][l], var[v][v][l]);
		}
	}
}

void addRepRestriction(long v){
	long l,u;
	if(source[v] == 'n'){
		for(l = 0; l < k; l++){
			fprintf(out,"1x%lu ", var[v][v][l]);
		}

		for(l = 0; l < k; l++){
			for(u = 0; u < v; u++){
				fprintf(out,"+1x%lu ", var[v][u][l]);
			}
			fprintf(out," <= %lu \n", k);
		}
	}
}

void initVar(){
	vari = 0;
	long i,l,j;
	for(i = 0; i < n; i++){
		for(l = 0; l < k; l++){
			source[i] = 's';
			for(j = 0;j < i; j++){
				if(!hasEdge(i,j)) source[i] = 'n';
			}
			if(source[i] == 'n'){
				var[i][i][l] = vari++;
				for(j = i+1;j < n; j++){
					if(!hasEdge(i,j)) var[i][j][l] = vari++;
				}
			}
		}
	}
}



int main(int argc, char *argv[]){
	FILE* fin = fopen(argv[1], "r");
	FILE* fout = fopen(argv[2], "w");
	k = atol(argv[3]);
	void readGraph(fin);
	out = fout;
	n = gn;
	initVar();
	long v,u,w;
	for(v = 0; v < n; v++){
		addRepRestriction(v);
		for(u = v+1; u < n; u++){
			if(!hasEdge(v,u))addSingleRestriction(v,u);
			for(w = u+1; w < n; w++){
				if(hasEdge(w,u) && !hasEdge(v,u) && !hasEdge(v,w)) addEdgeRestriction(v,u,w);
			}
		}
	}
	return 0;
}
